﻿using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using DevTeam;
using System;
using System.Data;
using System.Windows.Forms;

namespace ConfExpert.Forms.Depo._7C
{
    public partial class Garni : XForm
    {
        int CKBatchId = -1;
        public Garni(int ckBatchId)
        {
            InitializeComponent();
            TAM.GPgrnTableAdapter = new Datasets.MyDataTableAdapters.GPgrnTableAdapter();

            this.CKBatchId = ckBatchId;
            this.Text += "- " + AppSession.Lookups.CKBatch.FindByCKBatchId(CKBatchId).Notes;
        }

        BindingSource bs;
        private void Garni_Load(object sender, EventArgs e)
        {
            
            bs = new BindingSource(ds, "GPgrn");
            AddBsToList(bs);
            InitGridView(gridView1, bs);
            GetDetails("GPgrn", "GetHelper", "GPgrn", CKBatchId);
            //TAM.GPgrnTableAdapter.Fill(ds.GPgrn);
            gridView1.AddSummary();


            btnUpd.Visibility = ytk(84) ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never;
            btnUpd.ItemClick += btnUpd_ItemClick;

            btnKaydet.ItemClick += btnKaydet_ItemClick;
            gridView1.BestFitColumns();

            //GridManager gm = GridManager.GetManager(gridView1);
            ////if (AmI(17, 92, 120))
            //gm.GridMenu.AddMenu("CK formunu güncelle", CKguncelle);

        }

        void btnUpd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            DataTable dt = ExecuteDataTable("Get7cTakipYeni", CKBatchId, 0, 0, 1);
            if (dt.Rows.Count > 0)
                using (OlusanFarklar of = new OlusanFarklar(dt))
                    of.ShowDialog();

            //Notify("Ara tablolar başarı ile güncellendi.");
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Save();
        }
    }
}